<template>
  <d2-container>
    <template slot="header">
      <div style="display: flex;width: 90%">
        <div style="width: 80%">
          <el-descriptions title="评分详情">
            <el-descriptions-item label="考核号">{{ revalues.appraisalNo }}</el-descriptions-item>
            <el-descriptions-item label="考核名称">{{ revalues.templateName}}</el-descriptions-item>
            <el-descriptions-item label="考核项">{{ revalues.assessName }}</el-descriptions-item>
            <el-descriptions-item label="考核类型">{{ revalues.assessType }}</el-descriptions-item>
            <el-descriptions-item label="创建时间">{{ revalues.createTime }}</el-descriptions-item>
            <el-descriptions-item label="审核人">{{ revalues.checkInfoName }}</el-descriptions-item>
            <el-descriptions-item label="部门">{{ revalues.departmentName }}</el-descriptions-item>
            <el-descriptions-item label="状态"><h2 style="margin: 0;"><span v-if="revalues.checkStatus===1">已评分</span></h2></el-descriptions-item>
            <el-descriptions-item label="评分方法"><el-tag size="mini">{{revalues.assessMethod}}</el-tag></el-descriptions-item>
          </el-descriptions>
        </div>
      </div>
      <div style="margin-left: 5%;width: 90%">
        <h2>您的评分信息：</h2>
        <div class="block" style="width: 100%">
          <el-slider
            v-model="score"
            disabled
            show-input>
          </el-slider>
        </div>
      </div>
    </template>

  </d2-container>
</template>

<script>
export default {
  name: 'showCheckDetail',
  created () {
    this.score = this.revalues.score
  },
  data () {
    return {
      fileList: [],
      textarea: '',
      fullscreenLoading: false,
      score: null
    }
  },
  methods: {
    submitUpload () {
      this.fullscreenLoading = true
      this.$refs.upload.submit()
      const fd = new FormData()
      this.fileList.map((item) => {
        fd.append('file', item.raw)
        fd.append('eid', this.revalues.eid)
        fd.append('uid', this.revalues.uid)
      })
      fd.append('selfEvaluation', this.textarea)
      this.$request({ url: '/selfAppraisal/fileUpload', method: 'post', data: fd })
        .then((res) => {
          if (res === 1) {
            this.$emit('submitUpload', 1)
            this.fullscreenLoading = false
          } else {
            this.$message.error('自评或文件不能为空')
            this.fullscreenLoading = false
          }
        })
    },
    beforeRemove (file, fileList) {
      this.$confirm(`确定移除 ${file.name}？`).then(res => {
        if (res === 'confirm') {
          this.fileList = []
        }
      })
    }
  },
  props: {
    revalues: {
      type: Object,
      default: null
    }
  }
}
</script>
